package cn.com.gas.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;

import cn.com.common.result.DataResult;
import cn.com.gas.entity.GasServerAreaEntity;
import cn.com.gas.service.GasServerAreaService;



/**
 * 分析通道关联表
 *
 * @author shaochangyang
 * @email l2l84o7o5@live.com
 * @date 2024-04-15 20:42:02
 */
@Controller
@RequestMapping("/gas/server/area")
public class GasServerAreaController {
    @Autowired
    private GasServerAreaService gasServerAreaService;



    @ApiOperation(value = "新增")
    @PostMapping("gasServerArea/add")
    @RequiresPermissions("gasServerArea:add")
    @ResponseBody
    public DataResult add(@RequestBody GasServerAreaEntity gasServerArea){
        gasServerAreaService.save(gasServerArea);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("gasServerArea/delete")
    @RequiresPermissions("gasServerArea:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        gasServerAreaService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("gasServerArea/update")
    @RequiresPermissions("gasServerArea:update")
    @ResponseBody
    public DataResult update(@RequestBody GasServerAreaEntity gasServerArea){
        gasServerAreaService.updateById(gasServerArea);
        return DataResult.success();
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "查询分页数据")
    @PostMapping("/list")
    // @RequiresPermissions("gasServerArea:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody GasServerAreaEntity gasServerArea){
        Page page = new Page(gasServerArea.getPage(), gasServerArea.getLimit());
        LambdaQueryWrapper<GasServerAreaEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(GasServerAreaEntity::getId, gasServerArea.getId());
        IPage<GasServerAreaEntity> iPage = gasServerAreaService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
